@extends('manage.layout')

@section('content')
    <section class="content-header">
        <h1>
           客户反馈
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Feedback</a></li>
        </ol>
        <div class="input-group margin">
            <form action="/feedback" method="get">
                <select style="width: 150px" id="sel"  name="type" class="form-control" onchange="select()">
                    @foreach($navigation as $value)
                        <option value="{{ $value['id'] }}">{{ $value['navigation'] }}</option>
                    @endforeach
                </select>

                <div style="float: left" id="form">
                    <input id="datepicker" style="width: 200px"  name="param" type="text" class="form-control">
                </div>
                <input  type="submit" class="btn btn-info btn-flat" value="Go!">
            </form>
        </div>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <a href="/feedback"  @if($typeid == '') class="btn btn-info" @else class="btn btn-default" @endif style="margin: 0 20px 0 0">全部</a>
                        @foreach($feedbackCategory as $value)
                            <a href="/feedback?id={{$value->id}}" @if($typeid == $value->id) class="btn btn-info" @else class="btn btn-default" @endif style="margin: 0 20px 0 0">{{$value->name}}</a>
                        @endforeach
                        {{--<h3 class="box-title">内容</h3>--}}
                        <span style="float:right;color: #bbb">共{{$count}}条结果</span>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table id="example2" class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                @foreach($navigation as $nav)
                                    <th>
                                        {{$nav['navigation']}}&nbsp;&nbsp;
                                        @if($nav['navigation'] == '提交时间')
                                            <a href="/feedback?type={{$type}}&param={{$param}}&id={{$typeid}}&orderBy=1"><i class="fa fa-arrow-up"></i></a>&nbsp;&nbsp;
                                            <a href="/feedback?type={{$type}}&param={{$param}}&id={{$typeid}}&orderBy=2"><i class="fa fa-arrow-down"></i></a>
                                        @endif
                                    </th>
                                @endforeach
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($feedback as $p)
                                <tr>
                                    <td>{{ $p['id'] }}</td>
                                    <td>{{ $p['create_time'] }}</td>
                                    <td>{{ $p['categoryName'] }}</td>
                                    <td>{{ $p['dd_id'] }}</td>
                                    <td>{{ $p['name'] }}</td>
                                    <td>{{ $p['phone'] }}</td>
                                    <td>{{ $p['qq'] }}</td>
                                    <td>
                                        <a class="btn btn-info btn-xs" href="javascript:getContent('{{$p['content']}}')">查看反馈内容<a>
                                        <a class="btn btn-danger btn-xs" href="javascript:delFeedback({{ $p['id'] }})">删除<a>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div style="text-align: center;">
                        {!! $feedback->appends(['type'=>$type,'param'=>$param,'typeid'=>$typeid,'orderBy'=>$orderBy,'count'=>$count])->links() !!}
                    </div>
                </div>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
@stop
@section('script')
	<script>
        function getContent(_content){
//            //页面层
//            layer.open({
//                type: 1,
//                skin: 'layui-layer-rim', //加上边框
//                area: ['420px', '240px'], //宽高
//                content: _content
//            });
            //自定页
            layer.open({
                type: 1,
                title:'反馈内容（点击阴影处关闭）',
                skin: 'layui-layer-molv', //样式类名
                closeBtn: 0, //不显示关闭按钮
                area: ['420px', '240px'], //宽高
                anim: 2,
                shadeClose: true, //开启遮罩关闭
                content: _content
            });
        }
		function delFeedback(id) {
            layer.confirm('删除后不可恢复，是否继续?', {
                btn:['确定','取消']
            },function() {
                $.ajax({
                    url: '/feedback/deleteFeedback',
                    type: "GET",
                    data: {id:id},
                    dataType: "json",
                    success: function(res) {
                        console.log(res);
                        if(res.error == 0) {
                            window.location.href = "feedback";
                            layer.msg(res.msg)
                        }
                        else {
                            layer.msg(res.msg)
                        }
                    }
                });
            });
        }
	</script>
@stop
